import { EntitySchema } from '@mikro-orm/core';

export class TypechoUsers {
  uid!: number;
  name?: string;
  password?: string;
  mail?: string;
  url?: string;
  screenName?: string;
  created?: number = 0;
  activated?: number = 0;
  logged?: number = 0;
  group?: string;
  authCode?: string;
  introduce?: string;
  assets?: number = 0;
  address?: string;
  pay?: string;
  customize?: string;
  vip?: number = 0;
  experience?: number = 0;
  avatar?: string;
  clientId?: string;
  bantime?: number = 0;
  posttime?: number = 0;
}

export const TypechoUsersSchema = new EntitySchema({
  class: TypechoUsers,
  properties: {
    uid: { primary: true, type: 'number' },
    name: { type: 'string', length: 32, nullable: true, unique: 'name' },
    password: { type: 'string', length: 64, nullable: true },
    mail: { type: 'string', length: 150, nullable: true, unique: 'mail' },
    url: { type: 'string', length: 150, nullable: true },
    screenName: { type: 'string', fieldName: 'screenName', length: 32, nullable: true },
    created: { type: 'number', nullable: true, default: 0 },
    activated: { type: 'number', nullable: true, default: 0 },
    logged: { type: 'number', nullable: true, default: 0 },
    group: { type: 'string', length: 16, nullable: true, default: 'visitor' },
    authCode: { type: 'string', fieldName: 'authCode', length: 64, nullable: true },
    introduce: { type: 'string', length: 255, nullable: true },
    assets: { type: 'number', nullable: true, default: 0 },
    address: { type: 'string', columnType: 'text', nullable: true },
    pay: { type: 'string', columnType: 'text', nullable: true },
    customize: { type: 'string', length: 255, nullable: true },
    vip: { type: 'number', nullable: true, default: 0 },
    experience: { type: 'number', nullable: true, default: 0 },
    avatar: { type: 'string', columnType: 'text', nullable: true },
    clientId: { type: 'string', fieldName: 'clientId', length: 255, nullable: true },
    bantime: { type: 'number', nullable: true, default: 0 },
    posttime: { type: 'number', nullable: true, default: 0 },
  },
});
